# delimit;
clear;
capture log close;
set more off;


cd D:\Data\workData\703201\vibeke\GP;
log using "Happy Doctor_Results.txt",text replace;


****************************************************;
* TABLE 1.--- DATA FROM KRASNIK ET AL. (1990). SEE TABLE NOTES;
****************************************************;

****************************************************;
* TABLE 2.-- SUMMARY STATISTICS FOR THE OUTCOME VARIABLE, BY CASE AND CONTROL GROUP AND BY PRE AND POST REFORM PERIOD;
* firstborn only;
***************************************************;
use infant2.dta,clear;
drop if zone==1;
drop if pre1==.;
keep if kpnrm==1 | kpnrm==2;
keep if oob==1;
char _dta[omit] "prevalent";
set seed 210177;
gen edm=udlm/12;
gen edf=udlf/12;



capture erase TAB2.rtf;

quietly generate x = uniform();



for Z in any bw lbw ptb vptb fg :

\regress x Z if pre==1 & case==1 
\		estadd mean
\		estadd sd
\		estimates store m1
\regress x Z if pre==0 & case==1
\		estadd mean
\		estadd sd
\		estimates store m2
\regress x Z if pre==1 & case==0
\		estadd mean
\		estadd sd
\		estimates store m3
\regress x Z if pre==0 & case==0
\		estadd mean
\		estadd sd
\		estimates store m4
\estout m* using TAB2.rtf, append cell(mean(fmt(3))  sd(par(`"="("' `")""')fmt(3))) stats(N) mlabels (,none) drop(_cons) style(fixed);

**********************************************************************************************************************;
**** TABLE 3.--SUMMARY STATISTICS FOR THE COVARIATES BY TREATMENT AND CONTROL GROUP AND BY PRE- AND POST-REFORM PERIOD;
**********************************************************************************************************************;
capture erase TAB3.rtf;

for Z in any  male agem  dane west nowest  singl  edm lincm  o4m  Docsex Docage Docagesq edf lincf  o4f  msingl mudlm mpnrf mo4f  mudlf  mqincf :

\regress x Z if pre==1 & case==1 
\		estadd mean
\		estadd sd
\		estimates store m1
\regress x Z if pre==0 & case==1 
\		estadd mean
\		estadd sd
\		estimates store m2
\regress x Z if pre==1 & case==0 
\		estadd mean
\		estadd sd
\		estimates store m3
\regress x Z if pre==0 & case==0 
\		estadd mean
\		estadd sd
\		estimates store m4
\estout m* using TAB3.rtf, append cell(mean(fmt(3))  sd(par(`"="("' `")""')fmt(3))) stats(N) mlabels (,none) drop(_cons) style(fixed);



**************************************************************************************;
* TABLE 2 & TABLE 3--SUMMARY STATISTICS, FINAL COLUMN, THE UNCONDITIONAL DD ESTIMATOR ;
**************************************************************************************;

use infant2.dta,clear;
drop if zone==1;
drop if pre1==.;
keep if kpnrm==1 | kpnrm==2;
keep if oob==1;
char _dta[omit] "prevalent";
set seed 210177;
gen edm=udlm/12;
gen edf=udlf/12;

capture erase TAB2_3_DD.rtf;
capture erase TAB2_3_DDx.rtf;

for Z in any bw lbw ptb vptb fg  male agem  dane west nowest  singl  edm lincm  o4m  Docsex Docage Docagesq edf lincf  o4f msingl mudlm mpnrf mo4f  mudlf  mqincf:
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12, i(kompnrm)  fe robust
\estimates store y1
\estout y* using TAB2_3_DD.rtf, append margin cells(b(star fmt(3)) se(par fmt(3))) keep(preca) label starlevels(* 0.10 ** 0.05 *** 0.01)
\estout y* using TAB2_3_DDx.rtf,append margin cells(b(star fmt(3)) se(par(`"="("' `")""')fmt(3))) keep(preca) label starlevels(* 0.10 ** 0.05 *** 0.01) stats(N);

*****************************************************************************;
* TABLE 4. (MAIN RESULT TABLE) THE EFFECT OF GP CAPITATION CONTRACTS ON INFANT HEALTH;
*****************************************************************************;
use infant2.dta,clear;
drop if zone==1;
drop if pre1==.;
keep if kpnrm==1 | kpnrm==2;
keep if oob==1;
char _dta[omit] "prevalent";
set seed 210177;


capture erase TAB4.rtf;
capture erase TAB4x.rtf;
for Z in any lgbw lbw ptb vptb fg :
\xi: xtreg Z pre case preca yb1-yb4 yb6-yb9 mb1-mb8 mb10-mb12 male amx1 amx3 amx4 singl west nowest udlm qm2-qm4 o4m udlf qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincf, i(kompnrm)  fe robust 
\estimates store c1
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx1 amx3 amx4 singl west nowest udlm qm2-qm4 o4m udlf qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf, i(kompnrm)  fe robust 
\estimates store c2
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 male amx1 amx3 amx4 singl west nowest udlm qm2-qm4 o4m udlf qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if agem<=26, i(kompnrm)  fe robust
\estimates store c3
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx1 amx3 amx4 singl west nowest udlm qm2-qm4 o4m udlf qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if agem<=26, i(kompnrm)  fe robust
\estimates store c4
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 male  amx1 amx3 amx4 singl west nowest udlm qm2-qm4 o4m udlf qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if agem>26 & agem<=30, i(kompnrm)  fe robust
\estimates store c5
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx1 amx3 amx4 singl west nowest udlm qm2-qm4 o4m udlf qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if agem>26 & agem<=30, i(kompnrm)  fe robust
\estimates store c6
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 male amx1 amx3 amx4 singl west nowest udlm qm2-qm4 o4m udlf qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if agem>30, i(kompnrm)  fe robust
\estimates store c7
\xi: xtreg Z pre case preca yb1-yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx1 amx3 amx4 singl west nowest udlm qm2-qm4 o4m udlf qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if agem>30, i(kompnrm)  fe robust
\estimates store c8
\estout c* using TAB4.rtf, append margin cells(b(star fmt(3))  se(par(`"="("' `")""')fmt(3))) keep(preca) label starlevels(* 0.10 ** 0.05 *** 0.01)
\estout c* using TAB4x.rtf,append margin cells(b(nostar fmt(3)) se(par(`"="("' `")""')fmt(3))) keep(preca) label starlevels(* 0.10 ** 0.05 *** 0.01)  stats(N);



**************************************************************************;
* APPENDIX TABLE A1:--SUMMARY STATISTICS FOR THE OUTCOMES, YOUNGER MOTHERS;
**************************************************************************;
capture erase TABA1_19.rtf;
capture erase TABA1_26.rtf;
capture erase TABA1_30.rtf;
use infant2.dta,clear;
drop if zone==1;
drop if pre1==.;
keep if kpnrm==1 | kpnrm==2;
keep if oob==1;
char _dta[omit] "prevalent";
set seed 210177;
gen edm=udlm/12;
gen edf=udlf/12;

quietly generate x = uniform();
for Z in any lgbw lbw ptb vptb fg :

\regress x Z if pre==1 & case==1 & agem<=26
\		estadd mean
\		estadd sd
\		estimates store m1
\regress x Z if pre==0 & case==1 & agem<=26
\		estadd mean
\		estadd sd
\		estimates store m2
\regress x Z if pre==1 & case==0 & agem<=26
\		estadd mean
\		estadd sd
\		estimates store m3
\regress x Z if pre==0 & case==0 & agem<=26
\		estadd mean
\		estadd sd
\		estimates store m4

\estout m* using TABA1_19.rtf, append cell(mean(fmt(3))  sd(par(`"="("' `")""')fmt(3))) stats(N) mlabels (,none) drop(_cons) style(fixed);

capture erase TABA1_26.rtf;

for Z in any bw lbw ptb vptb fg :
\ regress x Z if pre==1 & case==1  & agem>26 & agem<=30
\		estadd mean
\		estadd sd
\		estimates store m1
\ regress x Z if pre==0 & case==1 & agem>26 & agem<=30
\		estadd mean
\		estadd sd
\		estimates store m2
\ regress x Z if pre==1 & case==0 & agem>26 & agem<=30
\		estadd mean
\		estadd sd
\		estimates store m3
\ regress x Z if pre==0 & case==0 & agem>26 & agem<=30
\		estadd mean
\		estadd sd
\		estimates store m4

\estout m* using TABA1_26.rtf, append cell(mean(fmt(3))  sd(par(`"="("' `")""')fmt(3))) stats(N) mlabels (,none) drop(_cons) style(fixed);



capture erase TABA1_30.rtf;

for Z in any bw lbw ptb vptb fg :
\regress x Z if pre==1 & case==1  & agem>30
\		estadd mean
\		estadd sd
\		estimates store m1
\regress x Z if pre==0 & case==1  & agem>30
\		estadd mean
\		estadd sd
\		estimates store m2
\regress x Z if pre==1 & case==0  & agem>30
\		estadd mean
\		estadd sd
\		estimates store m3
\regress x Z if pre==0 & case==0  & agem>30
\		estadd mean
\		estadd sd
\		estimates store m4

\estout m* using TABA1_30.rtf, append cell(mean(fmt(3))  sd(par(`"="("' `")""')fmt(3))) stats(N) mlabels (,none) drop(_cons) style(fixed);





************************************************************************;
* APPENDIX TABLE A2:-- SUMMARY STATISTICS FOR THE CONTROL VARIABLES, SEPERATELY FOR YOUNGER, PRIME AGE AND OLDER MOTHERS;
************************************************************************;
capture erase TABA2_19.rtf;
capture erase TABA2_26.rtf;
capture erase TABA2_30.rtf;

use infant2.dta,clear;
drop if zone==1;
drop if pre1==.;
keep if kpnrm==1 | kpnrm==2;
keep if oob==1;
char _dta[omit] "prevalent";
gen edm=udlm/12;
gen edf=udlf/12;
set seed 210177;
quietly generate x = uniform();



for Z in any male nsib yobm agem  dane west nowest  singl  edm lincm  o4m  Docsex Docage Docagesq edf lincf  o4f msingl mudlm mpnrf mo4f  mudlf  mqincf:
\regress x Z if pre==1 & case==1 & mpnrf!=1 & agem<=26
\		estadd mean
\		estadd sd
\		estimates store m1
\regress x Z if pre==0 & case==1 & mpnrf!=1 & agem<=26
\		estadd mean
\		estadd sd
\		estimates store m2
\regress x Z if pre==1 & case==0 & mpnrf!=1 & agem<=26
\		estadd mean
\		estadd sd
\		estimates store m3
\regress x Z if pre==0 & case==0 & mpnrf!=1 & agem<=26
\		estadd mean
\		estadd sd
\		estimates store m4
\estout m* using TABA2_19.rtf, append cell(mean(fmt(3))  sd(par(`"="("' `")""')fmt(3))) stats(N) mlabels (,none) drop(_cons) style(fixed);

****************************************************************************;
*>26 &<=30;

use infant2.dta,clear;
drop if zone==1;
drop if pre1==.;
keep if kpnrm==1 | kpnrm==2;
keep if oob==1;
char _dta[omit] "prevalent";
gen edm=udlm/12;
gen edf=udlf/12;
set seed 210177;



quietly generate x = uniform();

for Z in any  male nsib yobm agem  dane west nowest  singl  edm lincm  o4m  Docsex Docage Docagesq  edf lincf  o4f msingl mudlm  mpnrf mo4f  mudlf  mqincf :
\regress x Z if pre==1 & case==1 & agem>26 & agem<=30
\		estadd mean
\		estadd sd
\		estimates store m1
\regress x Z if pre==0 & case==1 & agem>26 & agem<=30
\		estadd mean
\		estadd sd
\		estimates store m2
\regress x Z if pre==1 & case==0 & agem>26 & agem<=30
\		estadd mean
\		estadd sd
\		estimates store m3
\regress x Z if pre==0 & case==0 & agem>26 & agem<=30
\		estadd mean
\		estadd sd
\		estimates store m4
\estout m* using TABA2_26.rtf, append cell(mean(fmt(3))  sd(par(`"="("' `")""')fmt(3))) stats(N) mlabels (,none) drop(_cons) style(fixed);



***********************************************************;
***>30;

use infant2.dta,clear;
drop if zone==1;
drop if pre1==.;
keep if kpnrm==1 | kpnrm==2;
keep if oob==1;
char _dta[omit] "prevalent";
gen edm=udlm/12;
gen edf=udlf/12;
set seed 210177;


quietly generate x = uniform();


for Z in any  male nsib yobm agem  dane west nowest  singl  edm lincm  o4m  Docsex Docage Docagesq edf lincf  o4f msingl mudlm mpnrf mo4f  mudlf  mqincf:
\regress x Z if pre==1 & case==1  & agem>30
\		estadd mean
\		estadd sd
\		estimates store m1
\regress x Z if pre==0 & case==1  & agem>30
\		estadd mean
\		estadd sd
\		estimates store m2
\regress x Z if pre==1 & case==0  & agem>30
\		estadd mean
\		estadd sd
\		estimates store m3
\regress x Z if pre==0 & case==0  & agem>30
\		estadd mean
\		estadd sd
\		estimates store m4
\estout m* using TABA2_30.rtf, append cell(mean(fmt(3))  sd(par(`"="("' `")""')fmt(3))) stats(N) mlabels (,none) drop(_cons) style(fixed);






*******************************************************************************************************************;
* APPENDIX TABLE A2--SUMMARY STATISTICS BY MATERNAL AGE, FINAL COLUMN: THE UNCONDITIONAL DD ESTIMATOR ;
*******************************************************************************************************************;


use infant2.dta,clear;
drop if zone==1;
drop if pre1==.;
keep if kpnrm==1 | kpnrm==2;
keep if oob==1;
char _dta[omit] "prevalent";
gen edm=udlm/12;
gen edf=udlf/12;
set seed 210177;



capture erase TABA2_DD.rtf;
capture erase TABA2_DDx.rtf;
for Z in any bw lbw ptb vptb fg  male agem  dane west nowest  singl  edm lincm  o4m  Docsex Docage Docagesq edf lincf  o4f msingl mudlm mpnrf mo4f  mudlf  mqincf:


\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 if agem<=26, i(kompnrm)  fe robust
\estimates store y1
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 if agem>26 & agem<=30, i(kompnrm)  fe robust
\estimates store y2
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 if agem>30, i(kompnrm)  fe robust
\estimates store y3

\estout y* using TABA2_DD.rtf, append margin cells(b(star fmt(3)) se(par fmt(3))) keep(preca) label starlevels(* 0.10 ** 0.05 *** 0.01)
\estout y* using TABA2_DDx.rtf,append margin cells(b(star fmt(3)) se(par(`"="("' `")""')fmt(3))) keep(preca) label starlevels(* 0.10 ** 0.05 *** 0.01) stats(N);


***************************************************************************************************;
* APPENDIX TABLE A3.-- THE EFFECT OF GP CAPITATION CONTRACTS ON INFANT HEALTH BY PARITY AND MATERNAL AGE
***************************************************************************************************;

capture erase TABA3_ALL.rtf;
capture erase TABA3x_ALL.rtf;
* ALL MOTHERS;
use infant2.dta,clear;
drop if zone==1;
drop if pre1==.;
keep if kpnrm==1 | kpnrm==2;
char _dta[omit] "prevalent";

set seed 210177;

for Z in any lgbw lbw ptb vptb fg:
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx1 amx3 amx4 singl west nowest udlm qm2-qm4 o4m udlf qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf, i(kompnrm)  fe robust 
\estimates store a1
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx1 amx3 amx4 singl west nowest udlm qm2-qm4 o4m udlf qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if oob==1, i(kompnrm)  fe robust 
\estimates store a2
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx1 amx3 amx4 singl west nowest udlm qm2-qm4 o4m udlf qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if oob>1, i(kompnrm)  fe robust 
\estimates store a3
\log 
\estout a* using TABA3_ALL.rtf, append margin cells(b(star fmt(3))  se(par(`"="("' `")""')fmt(3))) keep(preca) label starlevels(* 0.10 ** 0.05 *** 0.01)
\estout a* using TABA3x_ALL.rtf,append margin cells(b(nostar fmt(3)) se(par(`"="("' `")""')fmt(3))) keep(preca) label starlevels(* 0.10 ** 0.05 *** 0.01)  stats(N);

* YOUNGER MOTHERS;
use infant2.dta,clear;

drop if zone==1;
drop if pre1==.;
keep if kpnrm==1 | kpnrm==2;
char _dta[omit] "prevalent";
set seed 210177;
keep if agem<=26;

for Z in any lgbw lbw ptb vptb fg :
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx1 amx3 amx4 singl west nowest udlm qm2-qm4 o4m udlf qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf, i(kompnrm)  fe robust 
\estimates store a1
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx1 amx3 amx4 singl west nowest udlm qm2-qm4 o4m udlf qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if oob==1, i(kompnrm)  fe robust 
\estimates store a2
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx1 amx3 amx4 singl west nowest udlm qm2-qm4 o4m udlf qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if oob>1, i(kompnrm)  fe robust 
\estimates store a3
\estout a* using TABA3_ALL.rtf, append margin cells(b(star fmt(3))  se(par(`"="("' `")""')fmt(3))) keep(preca) label starlevels(* 0.10 ** 0.05 *** 0.01)
\estout a* using TABA3x_ALL.rtf,append margin cells(b(nostar fmt(3)) se(par(`"="("' `")""')fmt(3))) keep(preca) label starlevels(* 0.10 ** 0.05 *** 0.01)  stats(N);

* PRIME AGE MOTHERS;
use infant2.dta,clear;
drop if zone==1;
drop if pre1==.;
keep if kpnrm==1 | kpnrm==2;
char _dta[omit] "prevalent";
set seed 210177;
keep if agem>26 & agem<30;
for Z in any lgbw lbw ptb vptb fg :
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx1 amx3 amx4 singl west nowest udlm qm2-qm4 o4m udlf qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf, i(kompnrm)  fe robust 
\estimates store a1
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx1 amx3 amx4 singl west nowest udlm qm2-qm4 o4m udlf qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if oob==1, i(kompnrm)  fe robust 
\estimates store a2
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx1 amx3 amx4 singl west nowest udlm qm2-qm4 o4m udlf qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if oob>1, i(kompnrm)  fe robust 
\estimates store a3

\estout a* using TABA3_ALL.rtf, append margin cells(b(star fmt(3))  se(par(`"="("' `")""')fmt(3))) keep(preca) label starlevels(* 0.10 ** 0.05 *** 0.01)
\estout a* using TABA3x_ALL.rtf,append margin cells(b(nostar fmt(3)) se(par(`"="("' `")""')fmt(3))) keep(preca) label starlevels(* 0.10 ** 0.05 *** 0.01)  stats(N);


* OLDER MOTHERS;
use infant2.dta,clear;
drop if zone==1;
drop if pre1==.;
keep if kpnrm==1 | kpnrm==2;
char _dta[omit] "prevalent";
set seed 210177;
keep if agem>30;
for Z in any lgbw lbw ptb vptb fg :
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx1 amx3 amx4 singl west nowest udlm qm2-qm4 o4m udlf qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf, i(kompnrm)  fe robust 
\estimates store a1
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx1 amx3 amx4 singl west nowest udlm qm2-qm4 o4m udlf qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if oob==1, i(kompnrm)  fe robust 
\estimates store a2
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx1 amx3 amx4 singl west nowest udlm qm2-qm4 o4m udlf qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if oob>1, i(kompnrm)  fe robust 
\estimates store a3
\estout a* using TABA3_ALL.rtf, append margin cells(b(star fmt(3))  se(par(`"="("' `")""')fmt(3))) keep(preca) label starlevels(* 0.10 ** 0.05 *** 0.01)
\estout a* using TABA3x_ALL.rtf,append margin cells(b(nostar fmt(3)) se(par(`"="("' `")""')fmt(3))) keep(preca) label starlevels(* 0.10 ** 0.05 *** 0.01)  stats(N);



****************************************************************************************************;
* APPENDIX TABLE A4.--THE EFFECT OF GP CAPITATION CONTRACT ON LOG BIRTH WEIGHT, ALL COVARIATES INCLUDED;
****************************************************************************************************;

use infant2.dta,clear;

drop if zone==1;
drop if pre1==.;
keep if oob==1;
keep if kpnrm==1 | kpnrm==2;
char _dta[omit] "prevalent";
set seed 210177;

capture erase TABA4.rtf;
capture erase TABA4x.rtf;

for Z in any lgbw:
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx1 amx3 amx4 singl west nowest udlm qm2-qm4 o4m udlf qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf, i(kompnrm)  fe robust 
\estimates store d1
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male singl west nowest udlm qm2-qm4 o4m udlf qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if agem<=26, i(kompnrm)  fe robust 
\estimates store d2
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male singl west nowest udlm qm2-qm4 o4m udlf qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if agem>26 & agem<=30, i(kompnrm)  fe robust 
\estimates store d3
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male singl west nowest udlm qm2-qm4 o4m udlf qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if agem>30, i(kompnrm)  fe robust 
\estimates store d4
\estout d* using TABA4.rtf, append margin cells(b(star fmt(3)) se(par fmt(3)))  label starlevels(* 0.10 ** 0.05 *** 0.01)
\estout d* using TABA4x.rtf,append margin cells(b(star fmt(3)) se(par(`"="("' `")""')fmt(3)))  label starlevels(* 0.10 ** 0.05 *** 0.01) stats(N);

*********************************************************************************;
* APPENDIX TABLE A5.-- THE EFFECT OF GP CAPITATION CONTRACTS ON BIRTH WEIGHT, FOR DIFFERENT BIRTH WEIGHT DUMMIES;
*********************************************************************************;

use infant2.dta,clear;

drop if zone==1;
drop if pre1==.;
keep if kpnrm==1 | kpnrm==2;
keep if oob==1;
char _dta[omit] "prevalent";
set seed 210177;


drop bwd1 bwd2 bwd3 bwd4 bwd5 bwd6 bwd7 bwd8 ;


gen bwd1=(bw<2250);
gen bwd2=(bw<2500);
gen bwd3=(bw<2750);
gen bwd4=(bw<3000);
gen bwd5=(bw<3250);
gen bwd6=(bw<3500);
gen bwd7=(bw<3750);
gen bwd8=(bw<4000);
gen bwd9=(bw<4250);


capture erase TABA5.rtf;
capture erase TABA5x.rtf;
for Z in num 1/9:

\xi: xtreg bwdZ pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx2 amx3 amx4 singl west nowest udlm qm2-qm4 o4m udlf qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf, i(kompnrm) cluster(kompnrm) fe robust 
\estimates store c1

\xi: xtreg bwdZ pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx2 amx3 amx4 singl west nowest udlm qm2-qm4 o4m udlf qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if agem<=26, i(kompnrm) cluster(kompnrm) fe robust
\estimates store c2

\xi: xtreg bwdZ pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx2 amx3 amx4 singl west nowest udlm qm2-qm4 o4m udlf qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if agem>26 & agem<=30, i(kompnrm) cluster(kompnrm) fe robust
\estimates store c3

\xi: xtreg bwdZ pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx2 amx3 amx4 singl west nowest udlm qm2-qm4 o4m udlf qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if agem>30, i(kompnrm) cluster(kompnrm)  fe robust
\estimates store c4
\log on
\estout c* using TABA5.rtf, append margin cells(b(star fmt(3)) se(par fmt(3))) keep(preca) label starlevels(* 0.10 ** 0.05 *** 0.01)
\estout c* using TABA5x.rtf,append margin cells(b(star fmt(3)) se(par(`"="("' `")""')fmt(3))) keep(preca) label starlevels(* 0.10 ** 0.05 *** 0.01) stats(N);





********************************************************************************************;
* APPENDIX TABLE A6: THE EFFECT OF GP CAPITATION CONTRACTS, BY MATERNAL AGE AND EDUCATION ;
********************************************************************************************;

use infant2.dta,clear;
drop if zone==1;
drop if pre1==.;
keep if kpnrm==1 | kpnrm==2;
keep if oob==1;
char _dta[omit] "prevalent";
set seed 210177;
gen udxx=udlm/12;

tab udxx;

gen ud12= 1 if udxx<=10;
replace ud12=2 if udxx>10 & udxx<14;
replace ud12=3 if udxx>=14;


capture erase TABA6.rtf;
capture erase TABA6x.rtf;
for Z in any lgbw lbw lgsvl ptb vptb fg :
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx1 amx3 amx4 singl west nowest qm2-qm4 o4m qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf, i(kompnrm)  fe robust 
\estimates store c1
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx1 amx3 amx4 singl west nowest qm2-qm4 o4m qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if ud12==1, i(kompnrm)  fe robust 
\estimates store c2
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx1 amx3 amx4 singl west nowest qm2-qm4 o4m qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if ud12==2, i(kompnrm)  fe robust 
\estimates store c3
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx1 amx3 amx4 singl west nowest qm2-qm4 o4m qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if ud12==3, i(kompnrm)  fe robust 
\estimates store c4

\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx1 amx3 amx4 singl west nowest qm2-qm4 o4m qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if agem<=26 , i(kompnrm)  fe robust
\estimates store c5
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx1 amx3 amx4 singl west nowest qm2-qm4 o4m qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if agem<=26 & ud12==1, i(kompnrm)  fe robust
\estimates store c6
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx1 amx3 amx4 singl west nowest qm2-qm4 o4m qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if agem<=26 & ud12==2, i(kompnrm)  fe robust
\estimates store c7
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx1 amx3 amx4 singl west nowest qm2-qm4 o4m qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if agem<=26 & ud12==3, i(kompnrm)  fe robust
\estimates store c8

\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx1 amx3 amx4 singl west nowest qm2-qm4 o4m qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if agem>26 & agem<=30 , i(kompnrm)  fe robust
\estimates store c9
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx1 amx3 amx4 singl west nowest qm2-qm4 o4m qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if agem>26 & agem<=30 & ud12==1, i(kompnrm)  fe robust
\estimates store c10
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx1 amx3 amx4 singl west nowest qm2-qm4 o4m qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if agem>26 & agem<=30 & ud12==2, i(kompnrm)  fe robust
\estimates store c11
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx1 amx3 amx4 singl west nowest qm2-qm4 o4m qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if agem>26 & agem<=30 & ud12==3, i(kompnrm)  fe robust
\estimates store c12


\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx1 amx3 amx4 singl west nowest qm2-qm4 o4m qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if agem>30 , i(kompnrm)  fe robust
\estimates store c13
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx1 amx3 amx4 singl west nowest qm2-qm4 o4m qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if agem>30 & ud12==1, i(kompnrm)  fe robust
\estimates store c14
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx1 amx3 amx4 singl west nowest qm2-qm4 o4m qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if agem>30 & ud12==2, i(kompnrm)  fe robust
\estimates store c15
\xi: xtreg Z pre case preca yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx1 amx3 amx4 singl west nowest qm2-qm4 o4m qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if agem>30 & ud12==3, i(kompnrm)  fe robust
\estimates store c16

\estout c* using TABA6.rtf, append margin cells(b(star fmt(3)) se(par(`"="("' `")""')fmt(3))) keep(preca) label starlevels(* 0.10 ** 0.05 *** 0.01)
\estout c* using TABA6x.rtf,append margin cells(b(nostar fmt(3)) se(par(`"="("' `")""')fmt(3))) keep(preca) label  starlevels(* 0.10 ** 0.05 *** 0.01) stats(N);

***************************************************;
*APPENDIX TABLE A7.--THE EFFECT OF GP CAPITATION CONTRACTS ON INFANT HEALTH, FALSIFICATION TEST SUING DATA BEFORE THE REFORM;
**************************************************;
use infant2.dta,clear;

keep if kpnrm==1 | kpnrm==2;
keep if oob==1;
gen pre2=(yob<1984) | (yob==1984 & mob<10);
replace pre2=. if (yob<1981) | (yob==1981 & mob<10);
replace pre2=. if (yob>1987) | (yob==1987 & mob>=10);
gen preca2=(pre2*case);
drop if pre2==.;
char _dta[omit] "prevalent";
set seed 210177;


capture erase TABA7.rtf;
capture erase TABA7X.rtf;

for Z in any lgbw lbw ptb vptb fg :
\xi: xtreg Z pre2 case preca2 yb4 yb6-yb9 mb1-mb8 mb10-mb12 male  amx1 amx3 amx4 singl west nowest udlm qm2-qm4 o4m udlf qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf, i(kompnrm)  fe robust 
\estimates store c1
\xi: xtreg Z pre2 case preca2 yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx1 amx3 amx4 singl west nowest udlm qm2-qm4 o4m udlf qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf, i(kompnrm)  fe robust 
\estimates store c2
\xi: xtreg Z pre2 case preca2 yb4 yb6-yb9 mb1-mb8 mb10-mb12 male amx1 amx3 amx4 singl west nowest udlm qm2-qm4 o4m udlf qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if agem<=26, i(kompnrm)  fe robust
\estimates store c3
\xi: xtreg Z pre2 case preca2 yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx1 amx3 amx4 singl west nowest udlm qm2-qm4 o4m udlf qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if agem<=26, i(kompnrm)  fe robust
\estimates store c4
\xi: xtreg Z pre2 case preca2 yb4 yb6-yb9 mb1-mb8 mb10-mb12 male amx1 amx3 amx4 singl west nowest udlm qm2-qm4 o4m udlf qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if agem>26 & agem<=30, i(kompnrm)  fe robust
\estimates store c5
\xi: xtreg Z pre2 case preca2 yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx1 amx3 amx4 singl west nowest udlm qm2-qm4 o4m udlf qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if agem>26 & agem<=30, i(kompnrm)  fe robust
\estimates store c6
\xi: xtreg Z pre2 case preca2 yb4 yb6-yb9 mb1-mb8 mb10-mb12 male amx1 amx3 amx4 singl west nowest udlm qm2-qm4 o4m udlf qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if agem>30, i(kompnrm)  fe robust
\estimates store c7
\xi: xtreg Z pre2 case preca2 yb4 yb6-yb9 mb1-mb8 mb10-mb12 Docsex Docage Docagesq  male amx1 amx3 amx4 singl west nowest udlm qm2-qm4 o4m udlf qf2-qf4 mpnrf mo4f mo4m  msingl mudlf mudlm mqincm mqincf if agem>30, i(kompnrm)  fe robust
\estimates store c8
\estout c* using TABA7.rtf, append margin cells(b(star fmt(3))  se(par(`"="("' `")""')fmt(3))) keep(preca2) label starlevels(* 0.10 ** 0.05 *** 0.01)
\estout c* using TABA7x.rtf,append margin cells(b(nostar fmt(3)) se(par(`"="("' `")""')fmt(3))) keep(preca2) label  stats(N);


exit, clear;

